package com.lzxzjy.pojo;

public class Book {
    private Integer bookId;               // 图书编号
    private String ISBN;                  // 国际标准书号
    private String bookName;              // 书名
    private String bookAuthor;            // 作者
    private String bookPublish;           // 出版社
    private Double bookPrice;             // 价格
    private String bookType;              // 类型
    private String bookLocation;          // 位置
    private Integer bookState;            // 图书状态


    // 构造函数
    public Book() {
    }

    public Book(Integer bookId, String ISBN, String bookName, String bookAuthor, String bookPublish, Double bookPrice, String bookType, String bookLocation, Integer bookState) {
        this.bookId = bookId;
        this.ISBN = ISBN;
        this.bookName = bookName;
        this.bookAuthor = bookAuthor;
        this.bookPublish = bookPublish;
        this.bookPrice = bookPrice;
        this.bookType = bookType;
        this.bookLocation = bookLocation;
        this.bookState = bookState;
    }

    // get 和 set 方法
    public Integer getBookId() {
        return bookId;
    }

    public void setBookId(Integer bookId) {
        this.bookId = bookId;
    }

    public String getISBN() {
        return ISBN;
    }

    public void setISBN(String ISBN) {
        this.ISBN = ISBN;
    }

    public String getBookName() {
        return bookName;
    }

    public void setBookName(String bookName) {
        this.bookName = bookName;
    }

    public String getBookAuthor() {
        return bookAuthor;
    }

    public void setBookAuthor(String bookAuthor) {
        this.bookAuthor = bookAuthor;
    }

    public String getBookPublish() {
        return bookPublish;
    }

    public void setBookPublish(String bookPublish) {
        this.bookPublish = bookPublish;
    }

    public Double getBookPrice() {
        return bookPrice;
    }

    public void setBookPrice(Double bookPrice) {
        this.bookPrice = bookPrice;
    }

    public String getBookType() {
        return bookType;
    }

    public void setBookType(String bookType) {
        this.bookType = bookType;
    }

    public String getBookLocation() {
        return bookLocation;
    }

    public void setBookLocation(String bookLocation) {
        this.bookLocation = bookLocation;
    }

    public Integer getBookState() {
        return bookState;
    }

    public void setBookState(Integer bookState) {
        this.bookState = bookState;
    }

    // 逻辑视图 （将图书状态转换成文字）
    public String getBookStateStr() {
        if (this.bookState == null) {
            return "未知";
        } else {
            return this.bookState == 10 ? "借出" : this.bookState == -11 ? "遗失" : "在馆";
        }
    }


    // toString 方法
    @Override
    public String toString() {
        return "Book{" +
                "bookId=" + bookId +
                ", ISBN='" + ISBN + '\'' +
                ", bookName='" + bookName + '\'' +
                ", bookAuthor='" + bookAuthor + '\'' +
                ", bookPublish='" + bookPublish + '\'' +
                ", bookPrice=" + bookPrice +
                ", bookType='" + bookType + '\'' +
                ", bookLocation='" + bookLocation + '\'' +
                ", bookState=" + getBookStateStr() +
                '}';
    }

    // 判空
    public boolean isEmpty() {
        return this.bookId == null && "".equals(this.ISBN) && "".equals(this.bookName) && "".equals(this.bookAuthor) && "".equals(this.bookPublish) && this.bookPrice == null && "".equals(this.bookType) && "".equals(this.bookLocation);
    }
}
